﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace Matchingo.Modules.StatusBarModule.Views
{
    public partial class StatusBarView : UserControl, IStatusBarView
    {
        #region ========== Local Members ===========

        private StatusBarViewModel ViewModel { get; set; }

        public UIElement RootElement
        {
            get { return LayoutRoot; }
        }

        #endregion

        #region ========== Constructors ==========

        public StatusBarView()
        {            
            InitializeComponent();
        }

        #endregion

        #region ========== Public Methods ==========

        public void Initialize(StatusBarViewModel model)
        {
            ViewModel = model;
            DataContext = ViewModel;

            // make sure the pulsating textbox starts out invisible (we will show/hide it to reduce overhead of 100% transparent)
            PulsingTextBlock.Visibility = Visibility.Collapsed;
        }

        public void StartTextPulse(string text)
        {
            PulsingTextBlock.Text = text;            
            Storyboard textPulseStoryboard = (Storyboard)this.Resources["TextPulse"];
            textPulseStoryboard.Begin();
            PulsingTextBlock.Visibility = Visibility.Visible;
        }

        public void StartComboPulse(string text)
        {
            ComboTextBlock.Text = text;
            Storyboard comboPulseStoryboard = (Storyboard)this.Resources["ComboPulse"];
            comboPulseStoryboard.Begin();
            ComboTextBlock.Visibility = Visibility.Visible;
        }

        public void StopTextPulse()
        {
            Storyboard textPulseStoryboard = (Storyboard)this.Resources["TextPulse"];
            textPulseStoryboard.Stop();
            PulsingTextBlock.Visibility = Visibility.Collapsed;
        }

        public void StopComboPulse()
        {
            Storyboard comboPulseStoryboard = (Storyboard)this.Resources["ComboPulse"];
            comboPulseStoryboard.Stop();
            ComboTextBlock.Visibility = Visibility.Collapsed;
        }

        #endregion
    }
}
